package com.jcl.recruit.resume.service;

import com.jcl.recruit.core.web.utils.RequestUtils;
import com.jcl.recruit.resume.logic.ResumeWorkLogic;
import com.jcl.recruit.resume.model.ResumeWork;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author 刘明新
 * @date 2018/8/6 上午11:15
 */
@Service
public class ResumeWorkService {

    @Autowired
    private ResumeWorkLogic resumeWorkLogic;

    public List<Map<String, Object>> selectResumeWorksByResumeId(Integer resumeId) {
        String corpCode = RequestUtils.getCorpCode();
        return resumeWorkLogic.findObjListByResumeId(corpCode, resumeId);
    }

    public int insertSelective(ResumeWork record) {
        return resumeWorkLogic.insert(record);
    }

    public int updateByPrimaryKeySelective(ResumeWork record) {
        return resumeWorkLogic.updateByPrimaryKey(record);
    }

    //合并新增和更新方法
    public void updateOrInsert(ResumeWork resumeWork) {
        if (resumeWork.getId() == null) {
            this.insertSelective(resumeWork);
        } else {
            this.updateByPrimaryKeySelective(resumeWork);
        }
    }

    //是否存在相应的工作经验
    public int isExitByResumeWork(ResumeWork resumeWork) {
        return resumeWorkLogic.isExitEntity(resumeWork);
    }

    //删除工作经历
    public int deleteResumeWorkById(Integer id) {
        return resumeWorkLogic.deleteById(id);
    }
}
